package at.chl.genetic.function.math.node;

import at.chl.genetic.function.math.random.MathRandomUtil;
import at.chl.genetic.function.math.request.MathFunctionRequest;
import at.chl.genetic.function.math.result.MathFunctionResult;
import at.chl.genetic.function.request.IGeneticFunctionRequest;
import at.chl.genetic.function.result.IGeneticFunctionResult;
import at.chl.genetic.node.IDecisionNode;

public abstract class AbstractMathDecisionNode implements IDecisionNode{

	private String hash;
	
	public String getHash() {
		return hash;
	}

	public void setHash(String hash) {
		this.hash = hash;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj!=null&&obj instanceof AbstractMathDecisionNode){
			AbstractMathDecisionNode node=(AbstractMathDecisionNode)obj;
			return getHash().equals(node.getHash());
		}
		return false;
	}
	
	public abstract MathFunctionResult evaluate(MathFunctionRequest request);
	
	@Override
	public IGeneticFunctionResult evaluate(IGeneticFunctionRequest request) {
		if(!(request instanceof MathFunctionRequest)){
			//TODO throw exception
		}
		return evaluate((MathFunctionRequest)request);
	}

	public String createHashCode(String hashSource) {
		
		return MathRandomUtil.createRandomHashCode(hashSource);
		
	}
	
	

}
